const ws = require('ws');
const wss = new ws.Server({
    port: 4000
});
wss.on('connection', (socket) => {
    console.log('Connection connected');
    socket.on('message', (msg) => {
        console.log(msg.toString());
        socket.send('Message received!');
    });
    socket.on('close', () => {
        console.log('Connection closed');
    });
    socket.on('disconnect', () => {
        console.log('Connection disconnected');
    });
});